package com.hmkj.core.model.index;

import com.hmkj.core.po.simulation.OrderSimulation;
import lombok.Data;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by 陌上人 on 2077/7/7 14:21.
 */
@Data
public class OrderSimulationModel extends OrderSimulation {

    //用户名
    private String userName;
    //头像
    private String avatar;
    //股票代码
    private String stockCode;
    //股票名称
    private String stockName;
    //收益率
    private String earnRate;
    //买价
    private BigDecimal buyDealPrice;
    //卖价
    private BigDecimal sellDealPrice;
    //盈亏
    private BigDecimal profitCount;
    //数量
    private Integer sellDealNumber;
    //是否订阅
    private Integer isSub;
    //订阅Id
    private Integer subId;
    //备注
    private String remark;

    //最新价
    private String lastPrice;
    //盈亏
    private String profit;
    //交易分配
    private BigDecimal tradeProfit;
    //浮动盈亏
    private BigDecimal currentProfit;
    private BigDecimal stopPrice;
    private Integer holdDay;
    private BigDecimal rise;
    //止盈价格
    private BigDecimal stopProfitPrice;

    public static boolean checkTradeDate() throws ParseException {
        Calendar c = Calendar.getInstance();
        if (c.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || c.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
            return false;
    }
        Date da = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        String now = sdf.format(da);
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        Calendar c3 = Calendar.getInstance();
        Calendar c4 = Calendar.getInstance();
        Calendar c5 = Calendar.getInstance();
        c1.setTime(sdf.parse("09:30:00"));
        c2.setTime(sdf.parse("14:55:00"));
        c3.setTime(sdf.parse(now));
        c4.setTime(sdf.parse("11:30:00"));
        c5.setTime(sdf.parse("13:00:00"));
        if (!(c3.compareTo(c1) > 0 && c3.compareTo(c4) < 0) && !(c3.compareTo(c5) > 0 && c3.compareTo(c2) < 0)) {
            return false;
        }
        return true;
    }
}
